package com.xty.xtyle.frames;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.xty.xtyle.MainActivity;
import com.xty.xtyle.R;
import com.xty.xtyle.analysis.AnalysisActivity;
import com.xty.xtyle.base.AbsFragment;
import com.xty.xtyle.detail.AddClothActivity;
import com.xty.xtyle.picture.PickPhotoDialog;

import static com.xty.xtyle.picture.PickPhotoDialog.SELECT_PIC_BY_TACK_PHOTO;

public class HomeFragment extends AbsFragment {

    MainActivity mainActivity;

    @Override
    public int getLayoutId() {
        return R.layout.fragment_home;
    }

    @Override
    public void initView() {
        mainActivity = (MainActivity) getActivity();
        findViewById(R.id.back).setVisibility(View.GONE);
        TextView title = findViewById(R.id.center_title);
        title.setText("Xtyle");
        title.setTextSize(25);
        /**
         * 进入添加页面
         */
        findViewById(R.id.right_add).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AddClothActivity.startActivity(view.getContext(), "");
            }
        });
        //跳转到衣架页面
        findViewById(R.id.cloth_scaffold).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mainActivity.shiftFragment(1);
            }
        });
        //跳转到混搭页面
        findViewById(R.id.home_mix).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mainActivity.shiftFragment(2);
            }
        });
        //跳转到统计分析页面
        findViewById(R.id.home_style).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(view.getContext(), AnalysisActivity.class));
            }
        });
        //跳转到到日历Calendar页面
        findViewById(R.id.home_can).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mainActivity.shiftFragment(3);
            }
        });

        initBar();
    }

    @Override
    public void freshData() {

    }

    //首页右上角添加衣服点击事件，点击进入添加页面
    void initBar() {
        findViewById(R.id.right_add).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               startActivity(new Intent(view.getContext(), AddClothActivity.class));
            }
        });
    }

}
